#ifndef DEF_PLAYER
#define DEF_PLAYER

#include "State.h"
#include <QColor>
#include "ClientSocket.h"

class Cards;

class Player : public QObject
{
    Q_OBJECT
    public:
        Player(Cards* cards, QTcpSocket * cli);
        void addState(State* state);
        bool removeState(State* state);
        const QColor& color() const { return m_color; }
        size_t ID() const {return m_number; }
        const QList<State*> ownedStates() const { return m_states; }
        size_t reinforcementLeft() const { return m_reinAvaible; }
        void addReinforcement (size_t n);
        void setReinforcement (size_t n);
        void delReinforcement (size_t n);
        size_t reinPerRound () const;
        void newRound() { addReinforcement(reinPerRound()); }
        bool isDefeated() const {return !m_states.size(); }
        QString name() const { return tr("Joueur %1").arg(m_number+1); }
        ClientSocket* socket() { return m_socket; }

    signals:

        void defeated();
        void ready();

    private slots:

        void changeLobbyState();

    private:

        bool m_ready;

        QList<State*> m_states;
        size_t m_number;
        QColor m_color;

        Cards* m_cards;

        size_t m_reinAvaible;

        ClientSocket * m_socket;
};

#endif // DEF_PLAYER
